<div class="modal-header">
    <h4 class="modal-title">添加用户</h4>
</div>

<div class="modal-body">
    <form class="form-horizontal" name="userForm" novalidate ng-submit="addUser()">
        <div class="form-group">
            <label class="col-sm-3 ">部门</label>

            <div class="col-sm-8">
                <ui-select ng-model="user.department" theme="bootstrap" onfocus="false"
                           on-select="selectDepartment($select.selected);" required>
                    <ui-select-match placeholder="选择部门">{{$select.selected.name}}</ui-select-match>
                    <ui-select-choices
                            repeat="d in departments | filter: $select.search">
                        <div ng-bind-html="d.name | highlight: $select.search"></div>
                    </ui-select-choices>
                </ui-select>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group" ng-if="user.department.name.trim()=='运输公司'">
            <label class="col-sm-3 ">运输公司</label>
            <div class="col-sm-8">
                <ui-select ng-model="user.userName" theme="bootstrap" onfocus="false"
                           on-select="selectShipCompany($select.selected);" required>
                    <ui-select-match placeholder="选择运输公司">{{$select.selected}}</ui-select-match>
                    <ui-select-choices
                            repeat="sc in user.shipCompanies | filter: $select.search">
                        <div ng-bind="sc | highlight: $select.search"></div>
                    </ui-select-choices>
                </ui-select>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 ">登录名</label>

            <div class="col-sm-8">
                <input type="text" class="form-control" ng-model="user.userId"
                       placeholder="请输入登录名" required>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group" ng-if="user.department.name.trim()!='运输公司'">
            <label class="col-sm-3 ">用户名</label>

            <div class="col-sm-8">
                <input type="text" class="form-control" ng-model="user.userName"
                       placeholder="请输入用户名" required>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 ">密码</label>

            <div class="col-sm-8">
                <input type="password" class="form-control" ng-model="user.userPassword"
                       placeholder="请输入密码" required>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 ">确认密码</label>

            <div class="col-sm-8">
                <input type="password" class="form-control" ng-model="user.confirmPassword"
                       placeholder="请再次输入密码" required>
                <span style="color: red" ng-show="user.userPassword!=user.confirmPassword">两次密码不一致</span>
            </div>
            <div class="col-sm-3"></div>
        </div>
    </form>
</div>

<div class="modal-footer">
    <div class="row">
        <div class="col-xs-4 col-xs-offset-1">
            <button class="btn btn-default btn-action" ng-click="cancel()">取 消</button>
        </div>
        <div class="col-xs-2"></div>
        <div class="col-xs-4">
            <button class="btn btn-primary btn-action" ng-disabled="loading||!userForm.$valid" ng-click="addUser()">
                确 定
            </button>
        </div>
    </div>
</div>



